#include "Item.h"

Item::Item(QGraphicsItem* parent) : QGraphicsItem(parent)
{
    setPos(0,0);

    setFlag(QGraphicsItem::ItemIsMovable);
    setFlag(QGraphicsItem::ItemIsSelectable);
    setCursor(Qt::OpenHandCursor);
}

QRectF Item::boundingRect() const
{
    return QRectF(-15.5, -15.5, 34, 34);
}


void Item::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    // qDebug() << this << "Item::paint" << _pos;
    Q_UNUSED(option);
    Q_UNUSED(widget);
    painter->setPen(Qt::NoPen);
    painter->setBrush(Qt::darkGray);
    painter->drawEllipse(_pos.x()+3-15, _pos.y()+3-15, 30, 30);
    painter->setPen(QPen(Qt::black, 1));
    painter->setBrush(QBrush(Qt::red));
    painter->drawEllipse(_pos.x()-15, _pos.y()-15, 30, 30);
}

/*
void Item::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
    if (event->button() != Qt::LeftButton) {
	event->ignore();
	return;
    }

    qDebug() << this << "Item::mousePressEvent";
    setCursor(Qt::ClosedHandCursor);
}

void Item::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
    qDebug() << this << "Item::mouseMoveEvent" << event->scenePos();
    
    setPos(event->scenePos());
    update();
    setCursor(Qt::OpenHandCursor);
}

void Item::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
    qDebug() << this << "Item::mouseReleaseEvent" << event->scenePos();
    
    update();
    setCursor(Qt::OpenHandCursor);
}
//*/

